home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Burning & Media
/
GB-PVR 1.2.13
/
GBPVR10213.msi
/
Cabs.w1.cab
/
SearchResults.aspx.cs612
< prev
next >
Wrap
Text File
|
2008-05-25
|
46KB
|
860 lines
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data.Common;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web;
using System.Xml;
using GBPVR.Public;
using GBPVRSchedule;
using gbweb.classes;
namespace gbweb
{
/// <summary>
/// Summary description for SearchResults.
/// </summary>
public partial class SearchResults : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected Settings guideParams;
protected ProgramTreeItem[] pgmTree;
protected int treeIdx;
private string sortOrder = string.Empty;
private ArrayList sortOrders;
private ArrayList displayProgrammeSort = new ArrayList();
Hashtable channelCache = new Hashtable();
protected void Page_Load(object sender, System.EventArgs e)
{
treeIdx = 0;
pgmTree = new ProgramTreeItem[10000];
guideParams = Global.Settings;
HttpCookie cookie = Request.Cookies["showSearchResults"];
if (!IsPostBack)
{
//If the user has opted to use the TreeView search results allow the user to see the sort order
//options otherwise do not show them
XmlNode pre = Global.Config.SelectSingleNode("/settings/PreShowPadding");
XmlNode post = Global.Config.SelectSingleNode("/settings/PostShowPadding");
prePadding.Text = pre.InnerText;
postPadding.Text = post.InnerText;
sr_searchResults.SelectedValue = cookie != null ? cookie.Value : "tree";
if (sr_searchResults.SelectedValue == "tree")
{
treeView.Visible = true;
footer.Visible = false;
treeViewSortOptions.Visible = true;
tableView.Visible = false;
//If the user has ExtendedEWA then dynamicaly add a button for Star Rating sort
if (ExtendedEWA.Initialize())
{
ListItem starRating = new ListItem();
starRating.Text = "Star Rating";
starRating.Value = "star";
srtOrder.Items.Add(starRating);
ListItem originalAirDate = new ListItem();
originalAirDate.Text = "Original Air Date (oad)";
originalAirDate.Value = "originalAirDate";
srtOrder.Items.Add(originalAirDate);
}
//Set the selected search order to whatever was used on the search criteria page
string treeSortOrder = Convert.ToString(Session["SearchResultsOption"]);
if (treeSortOrder != null)
{
srtOrder.SelectedValue = sortOrder;
}
else
{
cookie = Request.Cookies["SearchSortOrder"];
srtOrder.SelectedValue = cookie != null ? cookie.Value : "title";
}
//Store the selected display (table or tree) in the cookie for the next search
cookie = new HttpCookie("showSearchResults", sr_searchResults.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
}
else
{
treeView.Visible = false;
footer.Visible = true;
treeViewSortOptions.Visible = false;
tableView.Visible = true;
}
if ((Request.Params["checkTitle"] != null) || (Request.Params["checkDescription"] != null) || (Request.Params["checkSubtitle"] != null) || (Request.Params["listChannels"] != null) ||
(Request.Params["matchTitle"] != null) || (Request.Params["matchDesc"] != null) || (Request.Params["matchSubtitle"] != null) || (Request.Params["matchUniqueID"] != null) ||
(Request.Params["textMinLength"] != null) && (Request.Params["textMinLength"].Length > 0) ||
((Request.Params["textMaxLength"] != null) && (Request.Params["textMaxLength"].Length > 0)) ||
Request.Params["startDate"] != null || Request.Params["startTime"] != null ||
Request.Params["endDate"] != null || Request.Params["endTime"] != null)
{
int minLength = int.MinValue;
int maxLength = int.MaxValue;
Session["startDate"] = "01/01/1901";
Session["startTime"] = "01:01 AM";
Session["endDate"] = "01/01/1901";
Session["endTime"] = "01:01 AM";
if ((Request.Params["textMinLength"] != null) && (Request.Params["textMinLength"].Length > 0)) minLength = int.Parse(Request.Params["textMinLength"]);
if ((Request.Params["textMaxLength"] != null) && (Request.Params["textMaxLength"].Length > 0)) maxLength = int.Parse(Request.Params["textMaxLength"]);
if ((Request.Params["startDate:textBox"] != null) && (Request.Params["startDate:textBox"].Length > 0))
{
Session["startDate"] = Request.Params["startDate:textBox"];
}
if ((Request.Params["startTime:textBox"] != null) && (Request.Params["startTime:textBox"].Length > 0))
{
Session["startTime"] = Request.Params["startTime:textBox"];
}
if ((Request.Params["endDate:textBox"] != null) && (Request.Params["endDate:textBox"].Length > 0))
{
Session["endDate"] = Request.Params["endDate:textBox"];
}
if ((Request.Params["endTime:textBox"] != null) && (Request.Params["endTime:textBox"].Length > 0))
{
Session["endTime"] = Request.Params["endTime:textBox"];
}
string[] channels = new string[0] { };
if (Request.Params["listChannels"] != null) channels = Request.Params["listChannels"].Split(',');
string[] genres = new string[0] { };
if (Request.Params["genreList"] != null) genres = Request.Params["genreList"].Split(',');
Session["checkTitle"] = Request.Params["checkTitle"] != null;
Session["checkDescription"] = Request.Params["checkDescription"] != null;
Session["checkSubtitle"] = Request.Params["checkSubtitle"] != null;
Session["matchTitle"] = Request.Params["matchTitle"] != null;
Session["matchDesc"] = Request.Params["matchDesc"] != null;
Session["matchSubtitle"] = Request.Params["matchSubtitle"] != null;
Session["matchUniqueID"] = Request.Params["matchUniqueID"] != null;
Session["textKeyWord"] = Request.Params["searchPhrase"];
Session["caseSensitive"] = Request.Params["caseSensitive"] != null;
Session["genreList"] = genres;
Session["minLength"] = minLength;
Session["maxLength"] = maxLength;
Session["channels"] = channels;
//Set the default recording Quality
quality.SelectedValue = Global.Settings.recordingQuality;
}
else
{
if (Request["sort"] == null)
{
Response.Redirect("Search.aspx");
}
}
}
else
{
if (sr_searchResults.SelectedValue == "tree")
{
//Store the selected sort order in the cookie for the next search
cookie = new HttpCookie("SearchSortOrder", srtOrder.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
treeView.Visible = true;
footer.Visible = false;
treeViewSortOptions.Visible = true;
tableView.Visible = false;
}
else
{
treeView.Visible = false;
footer.Visible = true;
treeViewSortOptions.Visible = false;
tableView.Visible = true;
}
}
//Store the selected display (table or tree) in the cookie for the next search
cookie = new HttpCookie("showSearchResults", sr_searchResults.SelectedValue);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
//Read the cookie for the sort order of the display
cookie = Request.Cookies["sortOrderSearch"];
sortOrder = cookie != null ? cookie.Value.Trim(',') : "channel,datetime,title";
//cookie.Value = "channel,datetime,title,status";
//sortOrder = "channel,datetime,title,status";
sortOrders = new ArrayList(sortOrder.Split(','));
string newSort = Request["sort"];
if (newSort != null)
{
if (sortOrders.Contains(newSort))
{
if (sortOrders[0].ToString() == newSort)
{
sortOrders.Remove(newSort);
sortOrders.Insert(0, newSort + " desc");
}
else
{
sortOrders.Remove(newSort);
sortOrders.Insert(0, newSort);
}
}
else
{
sortOrders.Remove(newSort + " desc");
sortOrders.Insert(0, newSort);
}
}
sortOrder = string.Join(",", (string[])sortOrders.ToArray(typeof(string)));
//Update the sort settings in the cookie for the next display
cookie = new HttpCookie("sortOrderSearch", sortOrder);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
}
protected void SearchResults_PreRender(object sender, System.EventArgs e)
{
SearchForEpisode(
(bool)Session["checkTitle"],
(bool)Session["checkDescription"],
(bool)Session["checkSubtitle"],
(bool)Session["matchTitle"],
(bool)Session["matchDesc"],
(bool)Session["matchSubtitle"],
(bool)Session["matchUniqueID"],
(string)Session["textKeyWord"],
(bool)Session["caseSensitive"],
(int)Session["minLength"],
(int)Session["maxLength"],
(string[])Session["channels"],
(string[])Session["genreList"],
(string)Session["startDate"],
(string)Session["startTime"],
(string)Session["endDate"],
(string)Session["endTime"]);
}
protected void hlRecord_Click(object sender, System.EventArgs e)
{
// schedule recordings
Schedule.Quality quality = 0;
switch (Request.Params["quality"].ToLower())
{
case "high":
quality = Schedule.Quality.High;
break;
case "medium":
quality = Schedule.Quality.Medium;
break;
case "low":
quality = Schedule.Quality.Low;
break;
case "custom1":
quality = Schedule.Quality.Custom1;
break;
case "custom2":
quality = Schedule.Quality.Custom2;
break;
}
Schedule scheduleHelper = Global.Schedule;
int prePad = Convert.ToInt32(prePadding.Text);
int postPad = Convert.ToInt32(postPadding.Text);
if (radioTime.SelectedValue == "once")
{
if (sr_searchResults.SelectedValue != "tree")
{
foreach (string param in Request.Params.Keys)
{
if (param.StartsWith("item"))
{
Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(param.Substring(4)));
Schedule myschedule = Global.Schedule;
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
bool scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
else
{
foreach (TreeNode node in TreeView1.CheckedNodes)
{
Programme programme = scheduleHelper.GetProgrammeByOID(System.Convert.ToInt32(node.Value));
Schedule myschedule = Global.Schedule;
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
bool scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
else
{
HybridDictionary processedRecordings = new HybridDictionary();
if (sr_searchResults.SelectedValue != "tree")
{
foreach (string param in Request.Params.Keys)
{
if (param.StartsWith("item"))
{
Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(param.Substring(4)));
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
string uniqueProgrammeKey = programme.getChannelOID().ToString() + ":" + programme.getTitle();
if (!processedRecordings.Contains(uniqueProgrammeKey))
{
//Set the max number of recordings to keep for the show
int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
if (keepRecordings.Text.ToString() != null)
{
try
{
keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
}
catch
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
}
else
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
Schedule myschedule = Global.Schedule;
if (radioTime.SelectedValue == "thisTime")
{
// schedule season recording for any day and this time
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
for (int i = 0; i < checkedDays.Items.Count; i++)
{
if (checkedDays.Items[i].Selected)
{
switch (checkedDays.Items[i].Text)
{
case "Monday":
dayList.Add(Schedule.Day.Monday);
break;
case "Tuesday":
dayList.Add(Schedule.Day.Tuesday);
break;
case "Wednesday":
dayList.Add(Schedule.Day.Wednesday);
break;
case "Thursday":
dayList.Add(Schedule.Day.Thursday);
break;
case "Friday":
dayList.Add(Schedule.Day.Friday);
break;
case "Saturday":
dayList.Add(Schedule.Day.Saturday);
break;
case "Sunday":
dayList.Add(Schedule.Day.Sunday);
break;
}
}
}
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
else
{
// schedule season recording for anyday anytime
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and thisany time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
for (int i = 0; i < checkedDays.Items.Count; i++)
{
if (checkedDays.Items[i].Selected)
{
switch (checkedDays.Items[i].Text)
{
case "Monday":
dayList.Add(Schedule.Day.Monday);
break;
case "Tuesday":
dayList.Add(Schedule.Day.Tuesday);
break;
case "Wednesday":
dayList.Add(Schedule.Day.Wednesday);
break;
case "Thursday":
dayList.Add(Schedule.Day.Thursday);
break;
case "Friday":
dayList.Add(Schedule.Day.Friday);
break;
case "Saturday":
dayList.Add(Schedule.Day.Saturday);
break;
case "Sunday":
dayList.Add(Schedule.Day.Sunday);
break;
}
}
}
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
// drop out after first season recording for the show
// (it really doesn't matter what we store here, but myRecording sounds usefull)
processedRecordings.Add(uniqueProgrammeKey, programme);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
}
else
{
foreach (TreeNode node in TreeView1.CheckedNodes)
{
Programme programme = scheduleHelper.GetProgrammeByOID(System.Convert.ToInt32(node.Value));
if (Convert.ToDouble(extendMinutes.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
string uniqueProgrammeKey = programme.getChannelOID().ToString() + ":" + programme.getTitle();
if (!processedRecordings.Contains(uniqueProgrammeKey))
{
//Set the max number of recordings to keep for the show
int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
if (keepRecordings.Text.ToString() != null)
{
try
{
keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
}
catch
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
}
else
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
Schedule myschedule = Global.Schedule;
if (radioTime.SelectedValue == "thisTime")
{
// schedule season recording for any day and this time
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
for (int i = 0; i < checkedDays.Items.Count; i++)
{
if (checkedDays.Items[i].Selected)
{
switch (checkedDays.Items[i].Text)
{
case "Monday":
dayList.Add(Schedule.Day.Monday);
break;
case "Tuesday":
dayList.Add(Schedule.Day.Tuesday);
break;
case "Wednesday":
dayList.Add(Schedule.Day.Wednesday);
break;
case "Thursday":
dayList.Add(Schedule.Day.Thursday);
break;
case "Friday":
dayList.Add(Schedule.Day.Friday);
break;
case "Saturday":
dayList.Add(Schedule.Day.Saturday);
break;
case "Sunday":
dayList.Add(Schedule.Day.Sunday);
break;
}
}
}
bool scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
else
{
// schedule season recording for anyday anytime
if (radioDay.SelectedValue == "anyDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for only this day and thisany time
else if (radioDay.SelectedValue == "thisDay")
{
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
for (int i = 0; i < checkedDays.Items.Count; i++)
{
if (checkedDays.Items[i].Selected)
{
switch (checkedDays.Items[i].Text)
{
case "Monday":
dayList.Add(Schedule.Day.Monday);
break;
case "Tuesday":
dayList.Add(Schedule.Day.Tuesday);
break;
case "Wednesday":
dayList.Add(Schedule.Day.Wednesday);
break;
case "Thursday":
dayList.Add(Schedule.Day.Thursday);
break;
case "Friday":
dayList.Add(Schedule.Day.Friday);
break;
case "Saturday":
dayList.Add(Schedule.Day.Saturday);
break;
case "Sunday":
dayList.Add(Schedule.Day.Sunday);
break;
}
}
}
bool scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
}
}
// drop out after first season recording for the show
// (it really doesn't matter what we store here, but myRecording sounds usefull)
processedRecordings.Add(uniqueProgrammeKey, programme);
Channel chnl = myschedule.GetChannelByOID(programme.getChannelOID());
Recordings.Items.Add(programme.getOID().ToString() + "@" + chnl.channelName + " " + programme.getTitle().ToString() + " " + programme.getStartTime().ToLongDateString() + " " + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString());
}
}
}
}
}
private void SearchForEpisode(
bool checkTitle, bool checkDesc, bool checkSubtitle,
bool matchTitle, bool matchDesc, bool matchSubtitle, bool matchUniqueID,
String searchFor, bool caseSensitive, int minLength, int maxLength,
string[] channels, string[] selectedGenre, string startdate, string starttime, string enddate, string endtime)
{
Schedule scheduleHelper = Global.Schedule;
ProgrammeDisplay displayProgramme = new ProgrammeDisplay();
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (sr_searchResults.SelectedValue != "tree")
{
createHeaderRow();
}
if (searchFor != null)
{
if (!caseSensitive)
{
searchFor = searchFor.ToUpper();
}
}
//Instantiate a new search engine
SearchEngine search = new SearchEngine();
//Set the date variables for search processing
search.setSearchDateTime(startdate, starttime, enddate, endtime);
//Call the method that will load an array with programmes that match the passed in search criteria
ArrayList ProgrammeArray = new ArrayList(search.SelectProgrammes(channels, selectedGenre, checkTitle, checkDesc, checkSubtitle, matchTitle, matchDesc, matchSubtitle, matchUniqueID, searchFor, caseSensitive, scheduleHelper, minLength, maxLength));
//Release resources held by the search engine object
search.Dispose();
if (sr_searchResults.SelectedValue == "tree")
{
foreach (Programme program in ProgrammeArray)
{
ScheduledRecording scheduledRecording = null;
if (knownRecordings.Contains(program.getOID()))
scheduledRecording = (ScheduledRecording)knownRecordings[program.getOID()];
createOutputTable(program, scheduleHelper.GetChannelByOID(program.getChannelOID()),
scheduledRecording, displayProgramme);
}
//Resize the array of ProgrammeTreeItems so that is isn't hogging up space.
Array.Resize(ref pgmTree, treeIdx);
TreeView1.Nodes.Clear();
//Fill the TreView Control with all the nodes in the correct format
displayProgramme.FillProgrammeTree(TreeView1, pgmTree, srtOrder.SelectedValue);
}
else
{
CSSProgrammeTableLoad tableLoad = new CSSProgrammeTableLoad();
foreach (Programme program in ProgrammeArray)
{
displayProgrammeSort.Add(program);
}
//Clear the arraylist of programmes to free up resources since we are done with it
ProgrammeArray.Clear();
//Sort the matching programmes into the choosen sort order
tableLoad.sortDisplay(sortOrders, displayProgrammeSort, false);
//Load the now sorted matching results into the table
while (displayProgrammeSort.Count > 0)
{
ScheduledRecording scheduledRecording = null;
Programme pgm = (Programme) displayProgrammeSort[0];
if (knownRecordings.Contains(pgm.getOID()))
scheduledRecording = (ScheduledRecording) knownRecordings[pgm.getOID()];
createOutputTable(pgm, scheduleHelper.GetChannelByOID(pgm.getChannelOID()),
scheduledRecording, displayProgramme);
displayProgrammeSort.RemoveAt(0);
}
}
if (Recordings.Items.Count > 0)
{
System.Web.UI.WebControls.DropDownList FailedRecordings = new System.Web.UI.WebControls.DropDownList();
string [] programmeInfo;
knownRecordings = scheduleHelper.LoadKnownRecordings();
for (int i = 0; i < Recordings.Items.Count; i++)
{
programmeInfo = Recordings.Items[i].Value.Split('@');
if (!knownRecordings.Contains(System.Convert.ToInt32(programmeInfo[0])))
{
FailedRecordings.Items.Add(programmeInfo[1]);
}
}
if (FailedRecordings.Items.Count > 0)
{
Recordings.Items.Clear();
System.Web.UI.WebControls.ListItem [] failures = new ListItem[FailedRecordings.Items.Count];
FailedRecordings.Items.CopyTo(failures,0);
Recordings.Items.AddRange(failures);
RecordMessage.Text = "Recordings That Failed to Schedule:";
Recordings.Visible = true;
RecordMessage.Visible = true;
}
else
{
Recordings.Items.Clear();
Recordings.Visible = false;
RecordMessage.Visible = false;
}
}
displayProgramme.Dispose();
}
private void createOutputTable(Programme programme, Channel channel, ScheduledRecording scheduledRecording, ProgrammeDisplay displayProgramme)
{
if (sr_searchResults.SelectedValue == "tree")
{
#region Code used to load a ProgrammeTreeItem Object with the correct formatted show information and then stuff in an Array
//Create a ProgrammeTreeItem to be loaded with the correct display information for the program
ProgramTreeItem treeItem = new ProgramTreeItem();
displayProgramme.FillProgrammeTreeArrayItem(treeItem, Server, programme, scheduledRecording, true, channel);
//Add the loaded ProgrammeTreeITem to the Array
pgmTree[treeIdx] = treeItem;
treeIdx = treeIdx + 1;
#endregion
}
else
{
#region Code used to load the table cells of a table row displaying the formatted show information
// Program Description
TableCell detailColDetails = new TableCell();
displayProgramme.FillProgrammeDisplay(Server, detailColDetails, programme, scheduledRecording, true);
TableRow detailRow = new TableRow();
TableCell detailCol1 = new TableCell();
if (scheduledRecording == null)
{
detailCol1.Text = "<input name=\"item" + programme.getOID().ToString() + "\" type=\"checkbox\" value=\"" + programme.getOID().ToString() + "\">";
}
detailCol1.CssClass = detailColDetails.CssClass;
detailRow.Cells.Add(detailCol1);
TableCell detailCol3 = new TableCell();
detailCol3.Text = channel.getName();
detailCol3.CssClass = detailColDetails.CssClass;
detailRow.Cells.Add(detailCol3);
detailRow.Cells.Add(detailColDetails);
TableCell detailCol4 = new TableCell();
detailCol4.Text = programme.getStartTime().ToLongDateString() + "<br><nobr>" + programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString() + "</nobr>";
detailCol4.CssClass = detailColDetails.CssClass;
detailRow.Cells.Add(detailCol4);
tableResults.Rows.Add(detailRow);
#endregion
}
}
private void createHeaderRow() {
TableRow headerRow = new TableRow();
TableCell col1 = new TableCell();
col1.CssClass = "header";
col1.Text = "<nobr><input type=\"checkbox\" class=\"selectall\" onclick=\"SelectAllCheckboxes(this);\"><b>Select</b></nobr>";
headerRow.Cells.Add(col1);
TableCell col3 = new TableCell();
col3.CssClass = "header";
col3.Text = "<a href=\"SearchResults.aspx?sort=channel\">Channel</a>" + getSortDescription(sortOrders[0], "channel");
headerRow.Cells.Add(col3);
TableCell col3a = new TableCell();
col3a.CssClass = "header";
col3a.Text = "<a href=\"SearchResults.aspx?sort=title\">Show</a>" + getSortDescription(sortOrders[0], "title");
headerRow.Cells.Add(col3a);
TableCell col4 = new TableCell();
col4.CssClass = "header";
col4.Text = "<a href=\"SearchResults.aspx?sort=datetime\">Air Date</a>" + getSortDescription(sortOrders[0], "datetime");
headerRow.Cells.Add(col4);
tableResults.Rows.Add(headerRow);
}
static string getSortDescription(object selectedSort, string thisSort)
{
if (selectedSort.ToString() == thisSort)
return " (asc)";
else if (selectedSort.ToString() == thisSort + " desc")
return " (desc)";
else
return string.Empty;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.PreRender += new System.EventHandler(this.SearchResults_PreRender);
}
#endregion
}
}